// 小模块

import Taro from '@tarojs/taro'
import { View, Image, Block } from '@tarojs/components'
import { navigateToVerfied } from '../../../utils/navigateToVerfied'
import {  } from './maxmodule'
import './mall.less'
import { useSelector } from 'react-redux'

function Minmoudles({ data }) {
  const __isVerified = useSelector(state =>state.userInfo.__isVerified)
  if (data.length === 0) {
    return null
  }
  // 小模块跳转
  function minMoudleNavigate(e) {
    const { index } = e.currentTarget.dataset
    switch (+index) {
      case 0:
        navigateToVerfied(
          __isVerified,
          '/subs/interactive/pages/say-create/say-create',
          'say'
        )
        break
      case 1:
        navigateToVerfied(
          __isVerified,
          '/subs/interactive/pages/activity-create/activity-create',
          'activity'
        )
        break
      case 2:
        // TODO
        // dispatch()
        // store.dispatch({
        //   type: 'setDynamicTabIndex',
        //   payload: 1
        // })
        Taro.switchTab({
          url: '/pages/tabbar/dynamic/dynamic'
        })
        break
      case 3:
        navigateToVerfied(
          __isVerified,
          '/subs/interactive/pages/qa/qa',
          'qa'
        )
        break
    }
  }
  return (
    <View className='d_between_center bg_ffffff p_l_r_32'>
      {data.map((item, index) => {
        return (
          <Block key={this}>
            <View
              data-index={index}
              onClick={minMoudleNavigate}
              className='min-moudle-item'
            >
              <Image
                className='min-moudle-item_img'
                src={item.icon}
              ></Image>
              <View>{item.title}</View>
            </View>
          </Block>
        )
      })}
    </View>
  )
}
export { Minmoudles }